package Student4;

public class Student4 {
    private String studentId;
    private String name;
    private String major;
    private double score;

    // 有参构造方法
    public Student4(String studentId, String name, String major) {
        this.studentId = studentId;
        this.name = name;
        this.major = major;
    }

    // getter/setter方法
    public String getStudentId() { return studentId; }
    public void setStudentId(String studentId) { this.studentId = studentId; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public String getMajor() { return major; }
    public void setMajor(String major) { this.major = major; }
    public double getScore() { return score; }
    public void setScore(double score) {
        if (score >= 0 && score <= 100) {
            this.score = score;
        } else {
            System.out.println("成绩不合法（必须0-100分）");
        }
    }

    // 显示信息
    public void showInfo() {
        System.out.println("学号：" + studentId + "，姓名：" + name +
                "，专业：" + major + "，成绩：" + score + "分");
    }
}
